
<script >
	function addElement() {

	  var ni = document.getElementById('myDiv');

	  var numi = document.getElementById('theValue');

	  var num = (document.getElementById('theValue').value -1)+ 2;

	  numi.value = num;

	  var newdiv = document.createElement('div');

	  var divIdName = 'my'+num+'Div';

	  newdiv.setAttribute('id',divIdName);
	  newdiv.setAttribute('style','float:left; width:100%');

	  newdiv.innerHTML = '<p><input type="hidden" id="userfile'+num+'" name="sanpham_hinhanh'+num+'" value=""/><img src="" width="50" id="imgdef'+num+'" name="imgdef'+num+'" height="40" style="float:left; border:#CCC 1px solid" /><input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open(\'Upfile.php?Dir=sanpham&amp;form=userfile'+num+'&img=imgdef'+num+'\',\'_upLoad\' ,\'height=220,width=450,resizable=no,scrollbars=yes\')") />&nbsp; <a href="javascript:;" onclick="removeElement(\''+divIdName+'\');">Xóa</a></p>';

	  ni.appendChild(newdiv);

	}
	function removeElement(divNum) {

	  var vl = document.getElementById('theValue');
	  vl.value= vl.value-1;
	  var d = document.getElementById('myDiv');

	  var olddiv = document.getElementById(divNum);

	  d.removeChild(olddiv);

	}
</script>
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">

	// O2k7 skin
tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		width : "700",
		height : "300",
		skin : "o2k7",
		plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,autosave,visualblocks",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,sub,sup,link,unlink,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		theme_advanced_path : false, 
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		

	});
				
/* Default skin */



</script>

<script language="javascript">
function validate_form(thisform)
{
with (thisform)
{
	
	
	if (validate_required(task_name,"Bạn chưa nhập tên công việc !")==false)
 	{task_name.focus();return false;}
	
	if (validate_required(contract_start,"Bạn chưa chọn ngày bắt đầu !")==false)
 	{contract_start.focus();return false;}
	if (validate_required(contract_end,"Bạn chưa chọn ngày kết thúc !")==false)
 	{contract_end.focus();return false;}
	if (validate_required(nguoitiepnhan,"Bạn chưa chọn người tiếp nhận !")==false)
 	{nguoitiepnhan.focus();return false;}
	if (validate_required(mucdo,"Bạn chưa chọn mức độ ưu tiên !")==false)
 	{mucdo.focus();return false;}
	
	

}
}
</script>



<?php 
$soanh=1;
?>

 <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="text-top">.:. Đăng ký lịch làm việc Dự án</td>
        </tr>
      </tbody></table>
      <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="t-l"></td>
          <td class="t-c"></td>
          <td class="t-r"></td>
        </tr>
        <tr class="light">
          <td class="c-l"></td>
          <td class="c-c" valign="top">
          	<form action="index.php?tn=xuly_addtask" onsubmit="return validate_form(this);" name="frmAddMessage" id="theform" method="post" enctype="multipart/form-data">
              <table border="0" cellpadding="0" cellspacing="0" height="10" width="100%">
                <tbody><tr class="light">
                  <td><img src="index2.php_files/spaces.gif" height="1" width="1"></td>
                </tr>
              </tbody></table>
              <table class="font_11" border="0" cellpadding="5" cellspacing="0" width="100%">
                <tbody>
          <tr class="light" id="tieudeyeucau" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td id="tieudeyeucau1" class="tdbg_2"><span><strong>Thông tin công việc</strong><span class="color_khancap"></span></span></td>
                  <td id="tieudeyeucau2" class="tdbg_2">:</td>
                  <td id="tieudeyeucau3" class="tdbg_2">
                  	<table>
                    	<tr>
                        	<td style="color:#060; font-weight:bold;">Tên công việc</td>
                            <td><input class="box_input" name="task_name" type="text" style="width:300px;"> </td>
                  		</tr>
                        <tr>
                        	<td style="color:#060; font-weight:bold;"> Ngày bắt đầu: </td>
                            <td>  <input class="box_input" name="contract_start" id="contract_start" type="text" width="15" />
                     <script type="text/javascript">
							$(function()
							{
								var arrayDayName=["CN","Hai","Ba","Tư","Năm","Sáu","Bảy"];
								var arrayMonthName=["Tháng 1","Tháng 2","Tháng 3","Tháng 4","Tháng 5","Tháng 6","Tháng 7","Tháng 8","Tháng 9","Tháng 10","Tháng 11","Tháng 12"];
								
								$('#contract_start').datepicker({
									yearRange: 'c-12:c+8',
									changeMonth: true,
									changeYear: true,
									dateFormat: 'dd-mm-yy',
									showAnim: 'slideDown',
									monthNamesShort:arrayMonthName,
									dayNamesMin:arrayDayName
								});										
							});	
						</script>
                        	</td>
                            <td style="color:#060; font-weight:bold;">Ngày kết thúc:  </td>
                            <td>  <input class="box_input" name="contract_end" id="contract_end" type="text" width="15" />
                     <script type="text/javascript">
							$(function()
							{
								var arrayDayName=["CN","Hai","Ba","Tư","Năm","Sáu","Bảy"];
								var arrayMonthName=["Tháng 1","Tháng 2","Tháng 3","Tháng 4","Tháng 5","Tháng 6","Tháng 7","Tháng 8","Tháng 9","Tháng 10","Tháng 11","Tháng 12"];
								
								$('#contract_end').datepicker({
									yearRange: 'c-12:c+8',
									changeMonth: true,
									changeYear: true,
									dateFormat: 'dd-mm-yy',
									showAnim: 'slideDown',
									monthNamesShort:arrayMonthName,
									dayNamesMin:arrayDayName
								});										
							});	
						</script> </td>
                        </tr>
                       </table>
                  </td>
                </tr>
                 <tr class="light" id="tieudeyeucau" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td id="tieudeyeucau1" class="tdbg_2"><span><strong>Yêu cầu thực hiện</strong><span class="color_khancap"></span></span></td>
                  <td id="tieudeyeucau2" class="tdbg_2">:</td>
                  <td id="tieudeyeucau3" class="tdbg_2">
                  <table>
                  <tr><td width="108" style="color:#060; font-weight:bold;"> 
                  Giao cho</td>
                  <td width="442"> 
                  <select name="nguoitiepnhan" id="room"  style="width:207px"> 
                  	<option value="">--Vui lòng chọn--</option> 
                  	<?php 
						$sqlgiao=mysql_query("select account_id,account_name,level from tb_account_admin where level!=3");
						while($rsgiao=mysql_fetch_array($sqlgiao))
						{
					?>  
                  	<option value="<?php echo $rsgiao['account_id'];?>" ><?php echo $rsgiao['account_name'];?></option> 
                  <?php }?>
                  </select>
                  </td>
               		
                    </tr>
                    <tr> 
                    	<td style="color:#060; font-weight:bold;">Người theo dõi</td>
                        <td>
                       		<div id="arr_nql_id">
									<input type="hidden" name="Nguoi_Quan_Ly_Khac" id="dsid_nql">
									
						</div>
                        	<input type="text" name="nguoitheodoi" style="width:380px" id="ds_nql"/>
                        	&nbsp
							 <div style="vertical-align:top; float:right;">
							 	<span style="padding-left:5px;" class="openp_dialog2">
									<img width="16px" height="16px" align="absmiddle" alt="pop" src="images/btn_Lookup.png">
								</span>
								<img width="16px" height="16px" align="absmiddle" onclick="document.getElementById(&#39;dsid_nql&#39;).value=&#39;&#39;;document.getElementById(&#39;ds_nql&#39;).value=&#39;&#39;;" alt="del" src="images/Clear.gif">
							 </div>
					   
                        </td>
                    </tr>
                    <tr>
                    	<td style="color:#060; font-weight:bold;">Mức độ ưu tiên  </td>
                         <td>
                              <select name="mucdo" id="mucdo"> 
                                <option value="">--Vui lòng chọn--</option> 
                                <option value="1">Thấp</option> 
                                <option value="2">Trung bình</option> 
                                <option value="3">Cao</option> 
                              </select>
                  		</td>
                    </tr>
                  </table>                  
                  
                  </td>
                </tr>
              
              
               
                <tr class="light" id="cauhoi" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)" bgcolor="">
                  <td class="tdbg_2" id="cauhoi1"><strong>Mô tả công việc</strong><span class="color_khancap">*</span></td>
                  <td class="tdbg_2" id="cauhoi2">:</td>
                  <td class="tdbg_2" id="cauhoi3">                     
                   	<div style="width:700px;">
					<textarea name="brief" id="txtnoidung" rows="15" cols="80" style="width: 80%"></textarea>  
                    	
                    </div>        
                </tr>
                <tr class="light" id="hinhanh" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td class="tdbg_2" id="hinhanh1">File đính kèm nếu có<br>
                    (*.gif, *.jpg, *.png, .doc, .pdf &lt; &nbsp;5000Kb)</td>
                  <td class="tdbg_2" id="hinhanh2">:</td>
                   <td id="myDiv" class="tdbg_2">
							<div style="float:left; width:100%; margin-top:5px;">
								<input type="hidden" id="userfile1" name="sanpham_hinhanh1"  value="<?php  echo $arr_hinhanh[0]?>"/>
								<?php if($arr_hinhanh[0]==""){$sanpham_hinhanh="upload/hinhanh/photo.jpg";}else $sanpham_hinhanh = $arr_hinhanh[0];?>
								<img src="<?php  echo $sanpham_hinhanh?>" width="50" id="imgdef1" name="imgdef1" height="40" style="float:left; border:#CCC 1px solid" />
								
								<input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open('Upfile.php?Dir=sanpham&amp;form=userfile1&img=imgdef1','_upLoad' ,'height=220,width=450,resizable=no,scrollbars=yes')") />
								
								<input type="hidden" value="<?php echo $soanh;?>" name="hdnsoanh" id="theValue" />
								<a href="javascript:;" onclick="addElement();">Thêm file đính kèm</a>
							</div>
							<?php
								for($i=2; $i<=$soanh;$i++){
								$hinhanh = $arr_hinhanh[$i-1];
							?>
								<div id="my<?php echo $i;?>Div" style="float:left; width:100%; margin-top:5px;">
									<input type="hidden" id="userfile<?php echo $i;?>" name="sanpham_hinhanh<?php echo $i;?>"  value="<?php  echo $hinhanh?>"/>
									<img src="<?php echo $hinhanh?>" width="50" id="imgdef<?php echo $i;?>" name="imgdef<?php echo $i;?>" height="40" style="float:left; border:#CCC 1px solid" />
								  
								   <input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open('Upfile.php?Dir=sanpham&amp;form=userfile<?php echo $i;?>&img=imgdef<?php echo $i;?>','_upLoad' ,'height=220,width=450,resizable=no,scrollbars=yes')") />
								 
								   <a href="javascript:;" onclick="removeElement('my<?php echo $i;?>Div');">Delete</a>
								</div>
							<?php
								}
							?>
						   </td>
                </tr>
                <tr class="light" id="bonut" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td class="tdbg_2" id="bonut1">&nbsp;</td>
                  <td class="tdbg_2" id="bonut2">&nbsp;</td>
                  <td class="tdbg_2" id="bonut3"><input class="buttonnew" name="submit" value="Gửi Yêu Cầu" onclick="SelectAll('NGUOIXULY')" type="submit">
                    &nbsp;
                    <input name="Submit2" class="buttonnew" value="&nbsp;Làm lại&nbsp;" type="reset"></td>
                </tr>
              </tbody></table>
              <table border="0" cellpadding="0" cellspacing="0" height="10" width="100%">
                <tbody><tr class="light">
                  <td><img src="index2.php_files/spaces.gif" border="0" height="1" width="1"></td>
                </tr>
              </tbody></table>
              
              
              
            </form></td>
          <td class="c-r"></td>
        </tr>
        <tr class="light">
          <td class="b-l"></td>
          <td class="b-c"></td>
          <td class="b-r"></td>
        </tr>
      </tbody></table>
      
<!--popup-->
<script>
	function call_list_user(url){
		var str = "";
		var str_id="";
		$("#nguoi_qlkhac input[type='checkbox']").each(function(){
			if($(this).is(':checked'))
			{
				if($(this).attr('name')!='DonVi'){
					str+= $(this).next().text() +', ';
					str_id+= $(this).val() +',';
				}
					
			}	
		});
		document.getElementById('ds_nql').value=str;
		document.getElementById('dsid_nql').value=str_id;
	}
	
function close_popup_nqlk(){
    $("#dialog2").dialog("close");
}

	$(document).ready(function(){
	$(".openp_dialog2").click(function(){
        $("#dialog2").dialog("open");
    });
	$("#dialog2").dialog({
        autoOpen: false,
        height: 500,
        width: 500,
        modal: true,
		resizable: false,
		buttons: {
				'Hủy bỏ': function() {
					
					$( this ).dialog( "close" );
				},
				'Chọn': function() {
					call_list_user('');
					$( this ).dialog( "close" );
				}

			}
    });
	
});
</script>

<div style="display: none; position: absolute; overflow: hidden; z-index: 1002; outline: 0px; height: auto; width: 500px; top: 82.5px; left: 432px;" class="ui-dialog ui-widget ui-widget-content ui-corner-all  ui-draggable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog2">
	<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" unselectable="on">
    	<span>Chọn đơn vị hoặc người dùng</span>
        <span class="ui-icon ui-icon-closethick" unselectable="on">close</span></div><div id="dialog2" style="padding-left: 0px; height: 436px; min-height: 86px; width: auto;" class="ui-dialog-content ui-widget-content">
<form id="frmNql" name="frmNql">
	<div id="nguoi_qlkhac" style="height:auto;">
		<div style="width:100%; height:auto;margin-left:20px;">
          <?php 
		
			$sql=mysql_query("select * from tb_room");
			
		?>
        <?php while($row=mysql_fetch_array($sql))
			{
				$room_id=$row['room_id'];
			?>
			<div style="float:left; width:50%;">
                <div style="color: #0070BA;width:100%;float:left;text-align:left;">
                    <input type="checkbox" onclick="selectReverse(&#39;frmNql&#39;,&#39;nql_56&#39;)" style="width:auto;" name="DonVi" value="56" class="item"><b><?php echo $row['room_name']?></b>
                </div>
				<div style="color: #0070BA;width:100%;float:left;margin-left:35px;">
				 <?php 
				$sql2=mysql_query("select account_id,room_id,account_name from tb_account_admin where room_id='$room_id'");
				?>
                <?php while($rs=mysql_fetch_array($sql2)){?>			  
                     <span class="nql_56" style="float:left;text-align:left;width:100%;">
                        <input id="nql_56_0" type="checkbox" style="width:auto;" name="arr_Cus_Id[]" value="<?php echo $rs['account_id'];?>" class="item">&nbsp;<b><?php echo $rs['account_name'];?></b>
                     </span>
                  <?php }?> 
                     
				</div>
              
		   </div>
		    <?php }?>
         
	</div>
    
	</form>
	
<!--end popup-->      